#include "UserInfo.h"
#include "tinyxml2.h"

UserInfo::UserInfo()
{}

UserInfo::UserInfo(std::string uName, std::string pass): userName(std::move(uName)), userPassword(std::move(pass))
{

}

std::string UserInfo::getUserName() const
{
	return userName;
}

std::string UserInfo::getPassword() const
{
	return userPassword;
}

std::string UserInfo::getDisplayName() const
{
	return userDisplayName;
}

std::string UserInfo::getGrade() const
{
	return userGrade;
}

unsigned int UserInfo::getAge() const
{
	return userAge;
}

void UserInfo::setAge(unsigned int age)
{
	userAge = age;
}

void UserInfo::setDisplayName(std::string displayName)
{
	userDisplayName = displayName;
}

void UserInfo::setGrade(std::string grade)
{
	userGrade = grade;
}

void UserInfo::setUserName(std::string uName)
{
	userName = std::move(uName);
}

void UserInfo::setPassword(std::string pass)
{
	userPassword = std::move(pass);
}

std::string UserInfo::toXmlString()
{
	tinyxml2::XMLDocument xDoc;

	auto node = xDoc.NewElement("User");
	xDoc.NewDeclaration("version=1.0");
	node->SetAttribute("userName", userName.c_str());
	node->SetAttribute("password", userPassword.c_str());
	node->SetAttribute("displayName", userDisplayName.c_str());
	xDoc.LinkEndChild(node);
	// print to string
	tinyxml2::XMLPrinter printer;
	xDoc.Accept(&printer);

	return std::string(printer.CStr());
}

UserInfo::~UserInfo()
{}
